package com.android.views;

import android.widget.Toast;

import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;

import com.android.dal.XMLWorkoutReader;

import android.media.AudioManager;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class AboutActivity extends Activity {
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_about);
		
		// Setting up basic activity requirements
		setVolumeControlStream(AudioManager.STREAM_MUSIC);
		
		// Get help button from the view
		Button btHelp = (Button) findViewById(R.id.btHelp);
		
		// Set the event that would occur on click
		btHelp.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Open a site that would have tutorials for this app
				// TEMP TEMP
				try {
					XMLWorkoutReader.ReadFile(getAssets().open("Example.xml"));
				} catch (XmlPullParserException e) {
					Toast.makeText(v.getContext(), "Error reading file. Writing to log...", Toast.LENGTH_SHORT).show();
					// TODO Write to log
					e.printStackTrace();
				} catch (IOException e) {
					Toast.makeText(v.getContext(), "Error reading file. Writing to log...", Toast.LENGTH_SHORT).show();
					// TODO Write to log
					e.printStackTrace();
				} catch (NumberFormatException e) {
					Toast.makeText(v.getContext(), "Error reading file. Writing to log...", Toast.LENGTH_SHORT).show();
					// TODO Write to log
					e.printStackTrace();
				}
				// TEMPY TEMPO
			}
		});
	}
}
